#!/bin/sh

FILES=$(find ".hx" . | grep -e ".hx$")

for f in $FILES
do
  echo $f
  sed -i 's/: *void/: Void/g;s/: *Boolean/: Bool/g;s/: *Object *{/: Dynamic {/g' $f # safe ones
  sed -i 's/int/Int/g;s/\([A-Za-z]\+\)Int/\1int/g' $f # This takes into consideration occurences of 'int' in common names like "point" etc.
  sed -i 's/: *\([A-Z][a-z]\+\)Number/: \1CANTTOUCHTHIS/g;s/: *Number\([A-Z][a-z]*\)/: CANTTOUCHTHIS\1/g;s/: *Number/: Float/g;s/CANTTOUCHTHIS/Number/g' $f
  sed -i 's/( \?\(.*\) is \(.*\) \?)/(Std.is(\1,\2))/g' $f # x is Y -> Std.is(x,Y)
  sed -i 's/ \?\([a-zA-Z0-9()\._]\+\) as \([A-Za-z]\+\) / cast(\1,\2)/g;s/= \(.*\) as \([A-Za-z]\+\)/= cast(\1,\2)/g' $f # x as Y -> cast(x,Y)
done
